import { loginA } from '@/api/login'

export default {
  namespaced: true,
  state: {
    userInfo: null,
    token: '',

  },
  mutation: {
    loginSuccess(state, payload) {
      state.useInfo = payload.useIfo
      state.token = payload.token
    },

    // resetUser(state) {
    //   state.userInfo = null,
    //   state.token = '',
    // }
  },
  actions: {
    async loginAction(context, payload) {
      const res = await loginA(payload.phone, payload.code)
      if (res.userInfo) {
        context.commit('loginSuccess', res)
      } else {
        context.commit('resetUser')
      }
    },

  },

}
